local MOD_util = {}
if false then
    do
        --这个直接复制到对应的位置执行就行
        --执行时机是加载模组的时候
        local registerlist = {}
        local oldLoadPrefabFile = GLOBAL.LoadPrefabFile
        function GLOBAL.LoadPrefabFile(filename, async_batch_validation, search_asset_first_path, ...)
            if registerlist[filename] then
                assert(not async_batch_validation or not search_asset_first_path,
                    "search_asset_first_path and async_batch_validation cannot both be defined")
                local fn = registerlist[filename]
                assert(fn, "Could not load file ")
                assert(type(fn) == "function", "Prefab file doesn't return a callable chunk: " .. filename)
                setfenv(fn, GLOBAL)
                local ret = { fn() }
                if ret then
                    for i, val in ipairs(ret) do
                        if type(val) == "table" and val.is_a and val:is_a(GLOBAL.Prefab) then
                            val.search_asset_first_path = search_asset_first_path
                            if async_batch_validation then
                                RegisterPrefabsImpl(val, function(prefab, asset)
                                    TheSim:AddBatchVerifyFileExists(asset.file)
                                end)
                            else
                                RegisterSinglePrefab(val)
                            end
                            GLOBAL.PREFABDEFINITIONS[val.name] = val
                        end
                    end
                end

                return ret
            end
            return oldLoadPrefabFile(filename, async_batch_validation, search_asset_first_path, ...)
        end

        function MOD_util:RegisterModPrefab(prefab_path, prefabfn)
            registerlist["prefabs/" .. prefab_path] = prefabfn
            table.insert(PrefabFiles, prefab_path)
        end
    end
end

local function prefabfn()
    local assets =
    {
        Asset("ANIM", "anim/rope.zip"),
    }

    local function fn()
        local inst = CreateEntity()

        inst.entity:AddTransform()
        inst.entity:AddAnimState()
        inst.entity:AddNetwork()

        MakeInventoryPhysics(inst)

        inst.AnimState:SetBank("rope")
        inst.AnimState:SetBuild("rope")
        inst.AnimState:PlayAnimation("idle")

        inst.pickupsound = "cloth"

        inst:AddTag("cattoy")

        MakeInventoryFloatable(inst, "small", 0.05)

        inst.entity:SetPristine()

        if not TheWorld.ismastersim then
            return inst
        end

        inst:AddComponent("inventoryitem")

        inst:AddComponent("inspectable")
        inst:AddComponent("stackable")

        MakeSmallBurnable(inst, TUNING.LARGE_BURNTIME)
        MakeSmallPropagator(inst)
        MakeHauntableLaunchAndIgnite(inst)

        inst:AddComponent("fuel")
        inst.components.fuel.fuelvalue = TUNING.MED_FUEL

        inst:AddComponent("tradable")

        return inst
    end

    return Prefab("rope231", fn, assets)
end
MOD_util:RegisterModPrefab("rope231", prefabfn)
